<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/FCKeditor.tld" prefix="fck" %>
<%@page import="java.util.*,model.*,util.*,control.*,java.text.*"%>
<%@ taglib uri="/WEB-INF/displaytag.tld" prefix="display"%>
<!DOCTYPE html>
<html>
<head>
    <title>查看历史记录</title>
    <meta charset="utf-8"/>
    <script  src='../../js/core.js'></script>
    <link type="text/css" rel='stylesheet' href="../../css/score.css"/>
</head>
<body>

            <%
           /*
           *验证权限
           *author 宋智洋
           *data 2011-11-26
           *update 胡瑾
           *data 2011-12-01
           *增加了userId
           */
			String flag = (String)session.getAttribute("flag");
			String userId = (String)session.getAttribute("userId");
			int studentId = Integer.parseInt(userId);
			String studentName=null;
						
			if (flag != "student"|| flag==null )
			{
			%>
            <script language="javascript">
				     alert("您没有学生权限,请重新登录"); window.location.href="../../index.jsp";
				    </script>
			<%}else{
				Student student = new Student();
				StudentControl sc = new StudentControl();
				student = sc.GetStudent(studentId);
				studentName = student.getStudentName();
			}
			%>
            
			
<div id="page">
    <header class="header">
        <p class="title"><%=studentName %>，欢迎你登录CAT测评系统</p>
        <p class="title">当前位置：首页&lt;&lt;查看成绩</p>
    </header>
  			<%	
				int k = 0;
				request.setCharacterEncoding("utf-8");
				int pages = ParamUtil.getInt(request,"pages",1);
				int rowsPerPage = ParamUtil.getInt(request,"pageSize",10);
				String testTime = ParamUtil.getString(request,"testTime");
				
				Problem problem = new Problem();
				ProblemControl pc = new ProblemControl();
				Answerlog answerlog = new Answerlog();
				AnswerlogControl ac = new AnswerlogControl();
			%>
<!--这个from控制了分页!!!-->
<form method="post" action="problem_history_list.jsp?testTime=<%=testTime %>">
<table class='main'>
	<thead>
      <tr>
        <td>序号</td>
        <td>试题编号</td>
        <td>题目</td>
        <td>正确与否</td>
        <td>正确答案</td>
      </tr>
    </thead>
    <tbody>
      <%
				List<Answerlog>list = new ArrayList<Answerlog>();
				list = (List)ac.GetAnswerlog();
				for(int i = 0; i<list.size();i++)
				{
					answerlog = list.get(i);
													
					if(answerlog.getStudentId()== studentId && answerlog.getTestTime().equals(testTime) )
					{
						problem = pc.GetProblem(answerlog.getId());
			
						String is_correct;
						if(answerlog.getFlag().equals("1"))
							is_correct = "正确";
						else
							is_correct = "错误";
			
						k++;
						String correct=problem.getCorrect();
						String correct_str=null;
						if(correct.equals("A"))
							correct_str = problem.getA();
						if(correct.equals("B"))
							correct_str = problem.getB();						
						if(correct.equals("C"))
							correct_str = problem.getC();
						if(correct.equals("D"))
							correct_str = problem.getD();
						
						
	 %>
      <tr>
        <td><%=k%></td>
        <td><%=answerlog.getId()%></td>
        <td> <div style="width:100%;height:100;overflow-x:hidden;overflow-y:scroll"> <%=problem.getContent()%></div></td>
        <td><%=is_correct%></td>
        <td><%=correct_str%></td>
      </tr>
      <%
					 }//if
				 }//for
			    	%>
			    	</tbody>
    </table>
	<center><%
		out.println(ScoreControl.pageInstance.getToolsMenu(pages));
	%></center>
    <p style='width:80%; margin:10px auto 170px;'><input type="button" onclick="javascript:window.history.go(-1)" class="btns fl br3" value="返   回"/></p>
  </form>
 <footer class="footer"><small>© 2012 Nenu</small></footer>
 </div>
</body>
</html>